Avoid final field modification in JUnit5 instrumentation#11752
Avoid final field modification in JUnit5 instrumentation#11752daniel-mohedano wants to merge 1 commit into
Conversation
Test Environment - sbt-scalatestJob Status: 🟢 success
Baseline: median of |
Test Environment - nebula-release-pluginJob Status: 🟢 success
Baseline: median of |
Test Environment - netflix-zuulJob Status: 🟢 success
Baseline: median of |
Test Environment - pass4sJob Status: 🟢 success
Baseline: median of |
Test Environment - reactive-streams-jvmJob Status: 🟢 success
Baseline: median of |
Test Environment - jolokiaJob Status: 🟢 success
Baseline: median of |
Test Environment - okhttpJob Status: 🟢 success
Baseline: median of |
Test Environment - sonar-javaJob Status: 🟢 success
Baseline: median of |
There was a problem hiding this comment.
More details
Three critical correctness invariants hold: (1) ThrowableCollectorFactoryWrapper is installed on NodeTestTaskContext (shared across all retry tasks), so factory.setSuppressFailures() correctly controls each retry even though currentTask is now a fresh NodeTestTask; (2) AbstractTestDescriptor.setParent() only sets the child's parent reference without addChild(), so the snapshot and retry descriptors are not injected into the parent's children list; (3) legacyCopy's new conditional uniqueId setter is correct — tryShallowClone already copies all fields including uniqueId, so the setter is only needed when the ID actually changes.
🤖 Datadog Autotest · Commit c73e0a4 · What is Autotest? · Any feedback? Reach out in #autotest
What Does This Do
TestTaskfor every retry, reusing the original parent context, instead of reusing and modifying the original test task. This approach is only supported for versions5.3.1+.TestDescriptorcloning method based onJupiterTestDescriptor#copyIncludingDescendants(UnaryOperator<UniqueId>)}, which also avoids manually setting the generateduniqueIdafter the cloning. This approach is only supported for versions5.13+.Motivation
Avoid failures in future JDKs due to JEP 500: Prepare to Make Final Mean Final.
Additional Notes
Running an example project on JDK26 with
JAVA_TOOL_OPTIONS=--illegal-final-field-mutation=debugproduced the following logs:The build containing the fix doesn't produce the logs.
Contributor Checklist
type:and (comp:orinst:) labels in addition to any other useful labelsclose,fix, or any linking keywords when referencing an issueUse
solvesinstead, and assign the PR milestone to the issue/merge. You can also:/merge --commit-message "..."/merge -c/merge -f --reason "reason"; please use this judiciously, as some checks do not run at the PR-level (note: the PR still needs to be mergeable, this will only skip the pre-merge build)Jira ticket: SDTEST-3867